module.exports = class extends think.Model {
    // 获取模型信息并缓存
    async get_model(id = null, field = null, extend = {}) {
        /* 读取缓存数据 */
        const list = await think.cache('get_model', () => {
            return this._get_model();
        }, { timeout: 365 * 24 * 3600 });
        if (!think.isEmpty(id) && think.isEmpty(field)) {
            return think._.find(list, { id: Number(id) });
        }
        if (!think.isEmpty(id) && !think.isEmpty(field)) {
            const arr = think._.find(list, { id: Number(id) });
            // console.log(arr);
            if (!think.isEmpty(arr)) {
                return arr[field];
            } else {
                return '';
            }
        }
        if (think.isEmpty(id) && think.isEmpty(field) && (!think.isEmpty(extend))) {
            return think._.filter(list, extend);
        }
    }
    // 获取模型信息
    /* 获取模型名称 */
    async _get_model() {
        const map = { 'status': 1, 'id': ['!=', 1] };
        return await this.where(map).select();
    }
}